using System.Collections.Generic;
using Common;

namespace SSettings
{
	public class ChannelSetting
	{
		private const string IsEnabled = "IsEnabled";

		private const string Wave = "Wave";

		private const string DyeCount = "DyeCount";

		private const string Dye = "Dye";

		private string IniName = Utility.GetApplicationPath() + "Channel.ini";

		private List<ChannelProperty> _AllChannelProperty = new List<ChannelProperty>();

		public List<ChannelProperty> AllChannelProperty
		{
			get
			{
				return _AllChannelProperty;
			}
			set
			{
				_AllChannelProperty = value;
			}
		}

		public ChannelSetting()
		{
			IniManager iniManager = new IniManager(IniName);
			ChannelProperty item = new ChannelProperty
			{
				IsEnabled = false
			};
			AllChannelProperty.Add(item);
			for (int i = 1; i < 100; i++)
			{
				item = new ChannelProperty();
				string section = "No" + i;
				string iniKeyValueForStr = iniManager.GetIniKeyValueForStr(section, "Wave");
				if (string.IsNullOrEmpty(iniKeyValueForStr))
				{
					if (i > 6)
					{
						break;
					}
					InitDefaultChannelProperty(item, i);
				}
				item.IsEnabled = true;
				item.WaveLength = iniKeyValueForStr;
				int iniKeyValueForInt = iniManager.GetIniKeyValueForInt(section, "DyeCount");
				List<string> list = new List<string>();
				for (int j = 1; j <= iniKeyValueForInt; j++)
				{
					string iniKeyValueForStr2 = iniManager.GetIniKeyValueForStr(section, "Dye" + j);
					list.Add(iniKeyValueForStr2);
				}
				item.DyeList = list;
				AllChannelProperty.Add(item);
			}
		}

		private void InitDefaultChannelProperty(ChannelProperty cp, int channelNo)
		{
			switch (channelNo)
			{
			case 1:
				cp.IsEnabled = true;
				cp.WaveLength = Utility.GetMessage("Channel1_Wave_length");
				cp.DyeList = new List<string>
				{
					Utility.GetMessage("Channel1_Wave_Fam"),
					Utility.GetMessage("Channel1_Wave_SybrGreen")
				};
				break;
			case 2:
				cp.IsEnabled = true;
				cp.WaveLength = Utility.GetMessage("Channel2_Wave_length");
				cp.DyeList = new List<string>
				{
					Utility.GetMessage("Channel2_Wave_VIC"),
					Utility.GetMessage("Channel2_Wave_HEX"),
					Utility.GetMessage("Channel2_Wave_JOE"),
					Utility.GetMessage("Channel2_Wave_TET")
				};
				break;
			case 3:
				cp.IsEnabled = true;
				cp.WaveLength = Utility.GetMessage("Channel3_Wave_length");
				cp.DyeList = new List<string>
				{
					Utility.GetMessage("Channel3_Wave_Rox"),
					Utility.GetMessage("Channel3_Wave_TexasRed")
				};
				break;
			case 4:
				cp.IsEnabled = true;
				cp.WaveLength = Utility.GetMessage("Channel4_Wave_length");
				cp.DyeList = new List<string> { Utility.GetMessage("Channel4_Wave_Cy5") };
				break;
			case 5:
				cp.IsEnabled = false;
				break;
			case 6:
				cp.IsEnabled = false;
				break;
			}
		}
	}
}
